﻿using System.Collections.Generic;
using System.Windows.Forms;
using NExplorer.AddIns.Samples.Commands;

namespace NExplorer.AddIns.Samples
{
	internal class SampleMenuBuilder : SingleCategoryMenuBuilder
	{
		protected override string Category
		{
			get { return "General"; }
		}

		protected override void AddCommands()
		{
			SelectionInfo selectionInfo = ServiceManager.Explorer.SelectionInfo;

			// This applies to one or more of anything.
			Add<AddPrefixCommand>();

			// Copy Contents: We only want to show the command when a single item, whose extension is in the
			// list of supported files, is selected.
			if (ServiceManager.Explorer.SelectedItems.Count == 1 && CopyContentsToClipboardCommand.Extensions.ContainsAny(selectionInfo.Extensions))
			{
				Add<CopyContentsToClipboardCommand>();
			}
			
            // Copy Path: Only add when any single item is selected.
            if (ServiceManager.Explorer.SelectedItems.Count == 1)
            {
                Add<CopyAsPathCommand>();
            }

            // Paste Clipboard to File: Only add when any single item is selected AND it's a directory AND
            // something is on the clipboard.
            if ((ServiceManager.Explorer.SelectedItems.Count == 1 && selectionInfo.IncludesDirectories) &&
                (Clipboard.ContainsAudio() || Clipboard.ContainsImage() || Clipboard.ContainsText()))
            {
                Add<PasteClipboardToFileCommand>();
            }
        }
	}
}
